<template>
  <div class="box">
    <div class="box-header">
      <div class="title">{{ props.title }}</div>
      <div class="desc">
        <span class="l" @click="changeVal(1)" :class="{ selected: selectVal === 1 }">Top5</span
        ><span class="inner"> | </span
        ><span class="r" @click="changeVal(2)" :class="{ selected: selectVal === 2 }">Bottom5</span>
      </div>
    </div>
    <div class="body">
      <div class="store-ranking">
        <div v-for="(item, index) in data" :key="index" class="ranking-item">
          <div class="row">
            <div class="item-text">{{ item.site_name }}</div>
            <div class="item-value">{{ item.site_score }}</div>
          </div>
          <div class="item-progress">
            <div class="progress-bar" :style="{ width: item.site_score + '%' }"></div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>

<script setup>
import { ref } from 'vue'
const props = defineProps({
  title: {
    type: String,
    default: '标题',
  },
  topData: {
    type: Array,
    required: true,
  },
  bottomData: {
    type: Array,
    required: true,
  },
})
const data = ref(props.topData)
const selectVal = ref(1)
const changeVal = (val) => {
  if (val === 1) {
    data.value = props.topData
    selectVal.value = 1
  } else {
    data.value = props.bottomData
    selectVal.value = 2
  }
}
// console.log('门店排名情况', props.data)
// const storeData = ref([
//   { site_name: '极氪汽车北京旗舰店', site_score: 96 },
//   { site_name: '极氪汽车上海旗舰店', site_score: 94 },
//   { site_name: '极氪汽车广州旗舰店', site_score: 90 },
//   { site_name: '极氪汽车成都旗舰店', site_score: 86 },
//   { site_name: '极氪汽车重庆旗舰店', site_score: 82 },
// ])
</script>

<style lang="scss" scoped>
.box {
  width: 462px;
  height: 275px;
  .box-header {
    display: flex;
    justify-content: space-between;
    align-items: center;
    width: 100%;
    height: 50px;
    padding-left: 40px;
    padding-right: 25px;
    background-image: url(@/assets/images/deliver/box-header-bg.png);
    background-size: cover;
    .title {
      font-family:
        Source Han Sans CN,
        Source Han Sans CN;
      font-weight: bold;
      font-style: normal;
      font-size: 26px;
      color: #ffffff;
      line-height: 50px;
    }
    .desc {
      font-family: Roboto, Roboto;
      font-size: 20px;
      font-weight: 500;
      .l {
        cursor: pointer;
        color: rgba(226, 67, 9, 0.5);

        // text-shadow:
        //   inset 0px 0px 6px rgba(255, 255, 255, 0.25),
        //   0px 2px 6px rgba(251, 169, 169, 0.2);
        // background: linear-gradient(90deg, #ff8574 0%, #d54b38 100%);
      }
      .inner {
        display: inline-block;
        width: 1px;
        height: 24px;
        margin: 0 6px -6px;
        background: linear-gradient(
          to bottom,
          rgba(255, 255, 255, 0),
          rgba(255, 255, 255, 1),
          rgba(255, 255, 255, 0)
        );
        overflow: hidden;
      }
      .r {
        cursor: pointer;
        color: rgba(226, 67, 9, 0.5);
      }
      .selected {
        color: rgba(255, 133, 116, 1);
      }
    }
  }
  .body {
    width: 100%;
    height: 230px;
    background: radial-gradient(0% 62% at 94% 46%, #232221 1%, rgba(54, 54, 54, 0.64) 100%);
  }
}
.store-ranking {
  background-color: #2a2a2a;
  color: #fff;
  .ranking-item:first-child .row .item-value {
    color: rgba(255, 90, 35, 1);
  }
  .ranking-item {
    padding: 12px 20px 0;
    .row {
      display: flex;
      justify-content: space-between;
      margin-bottom: 8px;
    }
    .item-text {
      font-size: 14px;
      font-family:
        Source Han Sans CN,
        Source Han Sans CN;
    }
    .item-value {
      font-size: 14px;
      font-family: Roboto, Roboto;
      font-weight: 500;
    }
    .item-progress {
      height: 4px;
      background-color: rgba(255, 55, 0, 0.1);
      overflow: hidden;
      .progress-bar {
        position: relative;
        height: 100%;
        background-image: linear-gradient(to right, rgba(255, 98, 0, 0.05), rgba(255, 66, 5, 1));
        transition: width 0.3s ease;
        &::after {
          content: '';
          position: absolute;
          top: 0;
          right: -4px; // 调整位置
          width: 6px; // 平行四边形的宽度
          height: 100%; // 平行四边形的高度
          background-color: #fff; // 白色背景
          background: linear-gradient(180deg, #ffffff 36%, #dea787 100%);
          box-shadow: -3px 0px 3px 0px rgba(255, 72, 0, 0.6);
          transform: skewX(-30deg); // 创建平行四边形效果
          z-index: 1; // 确保在进度条之上
        }
      }
    }
  }
}
</style>
